// eslint-disable prettier/prettier

// 根据 /packages目录下组件生成组件类侧边导航

import {createRouter ,createWebHashHistory,RouterOptions} from 'vue-router';

const routes  =[{
        title: '按钮',
        name:'Button',
        path:'/components/Button',
        component:() => import('packages/Button/docs/README.md')
      },{
        title: '图标',
        name:'Icon',
        path:'/components/Icon',
        component:() => import('packages/Icon/docs/README.md')
      },{
        title: '图片',
        name:'Image',
        path:'/components/Image',
        component:() => import('packages/Image/docs/README.md')
      },{
        title: '上传',
        name:'Upload',
        path:'/components/Upload',
        component:() => import('packages/Upload/docs/README.md')
      },{
        title: '卡片',
        name:'Card',
        path:'/components/Card',
        component:() => import('packages/Card/docs/README.md')
      },{
        title: '轮播图',
        name:'Swipe',
        path:'/components/Swipe',
        component:() => import('packages/Swipe/docs/README.md')
      },{
        title: '对话框',
        name:'Dialog',
        path:'/components/Dialog',
        component:() => import('packages/Dialog/docs/README.md')
      }]

const routerConfig= {
  history: createWebHashHistory(),
  routes,
  scrollBehavior(to:any,from:any){
    if(to.path !== from.path){
      return {top:0}
    }
  }
}

const router = createRouter(routerConfig as RouterOptions)

export default router